/*
 * COPYRIGHT. ShenZhen iByte Technology Co., Ltd. 2018.
 * ALL RIGHTS RESERVED.
 *
 * No part of this publication may be reproduced, stored in a retrieval system, or transmitted,
 * on any form or by any means, electronic, mechanical, photocopying, recording, 
 * or otherwise, without the prior written permission of ShenZhen iByte Network Technology Co., Ltd.
 *
 * Amendment History:
 * 
 * Date                   By              Description
 * -------------------    -----------     -------------------------------------------
 * Dec 3, 2018    Li.shangzhi         Create the class
 */
package com.github.icloud.elasticsearch.api.query;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;

import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.RangeQueryBuilder;
import org.junit.Test;

import com.github.icloud.elasticsearch.ElasticsearchClientBase;
/**
 * @FileName TermLeverQueries.java
 * @Description: 
 * @Date Dec 3, 2018 10:55:48 AM
 * @author Li.shangzhi
 * @version 1.0
 */
public class TermLeverQueries extends ElasticsearchClientBase{

//	@Test
//	public void iEsTermLeverQueries() throws Exception{
//		QueryBuilder qb = termQuery(
//				"user",    //field
//				"ibyte"    //text
//				);
//		iEsPrepareSearch(qb);
//	}


	@Test
	public void iEsRangeQuery() throws Exception{
//      gte() :范围查询将匹配字段值大于或等于此参数值的文档。
//      gt() :范围查询将匹配字段值大于此参数值的文档。
//      lte() :范围查询将匹配字段值小于或等于此参数值的文档。
//      lt() :范围查询将匹配字段值小于此参数值的文档。
//      from() 开始值 to() 结束值 这两个函数与includeLower()和includeUpper()函数配套使用。
//      includeLower(true) 表示 from() 查询将匹配字段值大于或等于此参数值的文档。
//      includeLower(false) 表示 from() 查询将匹配字段值大于此参数值的文档。
//      includeUpper(true) 表示 to() 查询将匹配字段值小于或等于此参数值的文档。
//      includeUpper(false) 表示 to() 查询将匹配字段值小于此参数值的文档。

//      RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("age");
//      rangeQueryBuilder.from(15);
//      rangeQueryBuilder.to(16);
//      rangeQueryBuilder.includeLower(true);
//      rangeQueryBuilder.includeUpper(true);
//      iEsPrepareSearch(rangeQueryBuilder);

		QueryBuilder qb = QueryBuilders.rangeQuery("age").gte(15).lte(16);
		iEsPrepareSearch(qb);
	}

}
